package com.vitabuybuy.tv.network

import com.library.common.net.NetUrl
import com.vitabuybuy.tv.dto.*
import rxhttp.IAwait
import rxhttp.wrapper.param.RxHttp
import rxhttp.wrapper.param.toResponse
import java.util.HashMap

/**
 * 作者：SimGa
 * 日期：2020/12/3
 * 时间：17:04
 * 包名：com.vitabuybuy.tv.network
 */
object TalentLiveRepository {
    fun getLiveList(
        show: Boolean,
        pageNumber: Int
    ): IAwait<List<PlayBackLiveListDto>> {
        val params = mapOf(
            Pair("page", pageNumber),
            Pair("size", 10),
            Pair("desc", "id")
        )
        return RxHttp.postJson(NetUrl.api_live_playback_list)
            .add("show", show)
            .addAll(params).toResponse()
    }

    fun isShowHome(
        show: Boolean,
        id: Int
    ): IAwait<String> {
        return RxHttp.postJson(NetUrl.api_live_updateShow)
            .add("show", !show)
            .add("id", id).toResponse()
    }

    fun deleteLivePlayBack(
        id: Int
    ): IAwait<String> {
        return RxHttp.postJson(NetUrl.api_live_delete)
            .add("id", id).toResponse()
    }

    fun getLiveNotice(
        pageNumber: Int
        ): IAwait<MutableList<LiveNoticeDto>> {
        val params = mapOf(
            Pair("page", pageNumber),
            Pair("size", 10),
            Pair("desc", "id")
        )
        return RxHttp.postJson(NetUrl.api_live_choose_notice)
            .addAll(params).toResponse()
    }

    fun startLive(liveParams: HashMap<String, Any?>, noticeList: ArrayList<HashMap<String,Int?>>): IAwait<SatrtLiveInfoDto> {
        return RxHttp.postJson(NetUrl.api_start_live)
            .add("live",liveParams)
            .add("agreementList",noticeList)
            .toResponse()
    }
}